package objects;

import java.awt.TrayIcon.MessageType;

import javax.swing.JOptionPane;

public class SettlementCard {
	public int ironReward = 0;
	public int goldReward = 0;
	public int woodReward = 0;
	public int stoneReward = 0;
	public CombatValue combatValue = new CombatValue(1, 0);

	public int points = 0;

	public String cardName = "";
	
	public SettlementCard(int ironReward, int goldReward, int woodReward, int stoneReward, int points, String cardName, CombatValue combatValue) {
		this.ironReward = ironReward;
		this.goldReward = goldReward;
		this.woodReward = woodReward;
		this.stoneReward = stoneReward;
		this.points = points;
		this.cardName = cardName;
		this.combatValue = combatValue;
	}
	
	public SettlementCard() {
		this.ironReward = 0;
		this.goldReward = 0;
		this.woodReward = 0;
		this.stoneReward = 0;
	}
	
	public boolean attackCard(PlayerInfo player){
		int attackerValue = 0;
		for (int i = 0; i < player.soldierCards.size(); i++) {
			attackerValue += player.soldierCards.get(i).combatValue.calculateValue();
		}
		int deffValue = combatValue.calculateValue();
		if(attackerValue > deffValue){
			captureCard(player);
			player.destroySoliers(deffValue);
			JOptionPane.showMessageDialog(null, "Angreifer: " + attackerValue + "\n Verteidiger: " + deffValue);
			return true;
		} else {
			JOptionPane.showMessageDialog(null, "Angreifer: " + attackerValue + "\nVerteidiger: " + deffValue);
			return false;
		}
	}
	
	public void captureCard(PlayerInfo player) {
		player.earn(goldReward, stoneReward, woodReward, ironReward);
		player.points += this.points;
		player.settlementCards.add(this);
	}
}
